<template>
    <div class="gender">
        <div class="top">
            <p class="title">男女比例</p>
            <p class="bg"></p>
        </div>
        <div class="sex">
            <div class="man">
                <span>男士</span>
                <img src="../images/man.png" alt="">
            </div>
            <div class="woman">
                <span>女士</span>
                <img src="../images/woman.png" alt="">
            </div>
        </div>
        <div class="rate">
            <p>男士58%</p>
            <p>女士52%</p>
        </div>
        <div class="chart" ref="chartRef"></div>
    </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue';
import * as echarts from 'echarts';

const chartRef = ref(null)

onMounted(() => {
    const MyChart = echarts.init(chartRef.value);
    const option = {
        title: {
            text: '男女比例',
            textStyle: {
                color: '#00ffff',
                fontSize: 16
            },
            left: '40%'
        },
        xAxis: {
            show: false,
            min: 0,
            max: 1
        },
        yAxis: {
            show: false,
            type: 'category'
        },
        series: [
            {
                type: 'bar',
                data:[.64],
                barWidth: 40,
                z: 10,
                itemStyle: {
                    color: '#409eff',
                    borderRadius: 20,
                },
                
            },
            {
                type: 'bar',
                data:[1],
                barWidth: 40,
                barGap: '-100%',
                itemStyle: {
                    color: '#f78989',
                    borderRadius: 20,
                },
                

            },
        ],
        gird: {
            left: 0,
            top: 0,
            bottom: 0,
            right: 0
        }

    }
    MyChart.setOption(option);
})

</script>

<style scoped lang="scss">
.gender {
    width: 100%;
    height: 100%;
    background-color: #fff;
    background: url(../images/dataScreen-main-lb.png);
    background-repeat: no-repeat;
    background-size: 100% 100%;
    margin-top: 10px;
    .top {
        margin-left: 20px;
        .title {
            color: #fff;
            font-size: 20px;
        }
        .bg {
            background: url(../images/dataScreen-title.png) no-repeat;
            background-size: 100% 100%;
            width: 68px;
            height: 7px;
            margin-top: 10px;
        }
    }
    .sex {
        display: flex;
        justify-content: center;
        margin-top: 40px;
        .man {
            width: 111px;
            height: 115px;
            margin: 20px ;
            background-image: url(../images/man-bg.png);
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
            color: #fff;
            span {
                position: relative;
                top: -18px;
            }
        }
        .woman {
            width: 111px;
            margin: 20px;
            height: 115px;
            background-image: url(../images/woman-bg.png);
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
            span {
                position: relative;
                top: -18px;
                color: #fff;
            }
        }
    }
    .rate {
        color: #fff;
        display: flex;
        justify-content: space-between;
        margin: 0 60px;
    }
    .chart {
        height: 100px;
    }
}
</style>